import org.junit.Test;

import java.util.Arrays;

import static org.junit.Assert.*;
public class NGuessNumberTest {

    @Test
    public void main() {
    }

    @Test
    public void generateAnswer() {
        for (int i = 0; i < 10; i++) {
            NGuessNumber nGuessNumber = new NGuessNumber();
            int[] array = nGuessNumber.generateAnswer();
            boolean b = true;
            //断言生成答案的数组长度为4
            assertEquals(4, array.length);

            //对数组进行排序
            Arrays.sort(array);
            for (int j = 0; j < array.length - 1; j++) {
                if (array[j] == array[j + 1])
                    b= true;
                else
                    b= false;
            }
            //断言不存在重复数字
            assertFalse(b);
            //断言不存在不在0~9之间的数字
            b=true;
            for (int k : array) {
                if (k < 0 || k > 9) {
                    b= false;
                }else
                    b= true;
            }
            assertTrue(b);
        }

        }

    @Test
    public void getPlayerInput() {
        NGuessNumber guessNumber= new NGuessNumber();
        int[] array = guessNumber.generateAnswer();
        //断言生成答案的数组长度为4
        assertEquals(4, array.length);
    }
}
